package com.xiaoshangkou.hellopra.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xiaoshangkou.hellopra.mapper.PermissionMapper;
import com.xiaoshangkou.hellopra.pojo.Permission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *
 * 关于数据库中的权限服务层
 *
 */
@Service
public class PermissionServeice {
    @Autowired
    private PermissionMapper permissionMapper;

    //分页查询权限
    public Page<Permission> findPermission(int page,int size){
        Page<Permission> permission = permissionMapper.selectPage(new Page<>(page, size), null);
        return permission;
    }

    //新建权限
    public void add(Permission permission){
        permissionMapper.insert(permission);
    }

    //根据peid删除权限
    public void delete(Integer peid){
        permissionMapper.deleteById(peid);
    }

    //根据peid查询权限内容
    public Permission findById(Integer peid){
        Permission permission = permissionMapper.selectById(peid);
        return permission;
    }

    //修改权限
    public void update(Permission permission){
        permissionMapper.updateById(permission);
    }

}
